<!--# layout("/common/leftmallout.html",{"jsBase":"/js/order/orderList/"}){ -->

 <script type="text/javascript" src="/plugins/oss/js/plupload.full.min.js"></script>
   <!--   <script type="text/javascript" src="/plugins/oss/ziyun_library.js"></script>-->
   <script type="text/javascript" src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fstyle%2Flib%2Fplupload.full.min.js"></script>
  <script type="text/javascript" src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fstyle%2Flibrary.js"></script>
   <script src="http://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/style/library.js"></script>
  <link rel="stylesheet" href="http://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/style/page.css">
   
<link rel="stylesheet" href="http://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/style/member.css">
<div class="center">
	<div class="section">
    	<!-------------面包屑--------------------->
            <div class="bread-crumbs">
                    <br/>
                </div>
        <!------------------主体结构--------------------->
        <div class="small-page">
         <!--左侧-->
        	
       <!-------左侧end-------->
       <!-------右侧-------->
            <div class="page-article">
                    <!--------------订单列表end------------>
            </div>
       <!-------右侧end-------->
        </div>
        <!------------------->
    </div>
</div>
<div class='boxDiv'>
<div class="box">分页内容要显示的地方</div>
</div>
 


<!--#} -->
<script>
layui.use(['index'], function(){
    var quoteOrderListIndex = layui.index
    quoteOrderListIndex.init();
});
</script>

<script>
function pageing(orderId,orderStatusGlobal){
	doAjax('/order/orderInfo/getOrderInfoRequestVos.json', 'post',{'orderId':orderId, 'orderStatus':orderStatusGlobal}, function(ret){
		if(ret.code=='200'){
			var total=ret.data.total;//总数据数量
			var totalPage=ret.data.totalPage;//总页数
			var current=ret.data.current;//第几页
			var size=ret.data.size;//每页数量
	        var orderInfoRequestVoList=ret.data.records;
	        $(function(){
		    	 var option={
		    	         pageNo:  current, // 初始页码
		    	         totalPages:  totalPage, //总页数
		    	         totalCount:  total, // 条目总数
		    	         slideSpeed:  600, // 缓动速度
		    	         jump:true, // 支持跳转
		    	         callback: function(page) {
		    	         		getData(orderId,orderStatusGlobal,page);
		    	             //根据当前页查数据
		    	         } // 回调函数
		    	     }
		    	     $(".box").paging(option);
		    	  })
		}
})
}


function getData(orderId,orderStatusGlobal,pageNo){
	doAjax('/order/orderInfo/getOrderInfoRequestVos.json', 'post', {'orderId':orderId, 'orderStatus':orderStatusGlobal, 'pageNo':pageNo}, function(ret){
		if(ret.code=='200'){
	        var orderInfoRequestVoList=ret.data.records;
	        var total=ret.data.total;//总数据数量
	        $(".page-article").empty();
	        var html='<div class="area_mend_head">'
		            +'<span>我的订单</span>'
		            +'<div class="searchFree">'
		            +'   <form action="/member/orders" method="get" id="search_form" style="display:inline-block;">'
		            +'      <select name="orderStatus" class="orderStatus " id="orderStatus">'
		            +'        	<option value="all">全部</option>'
		            +'           <option value="unauditing">待审核</option>'
		            +'           <option value="unpay">待付款</option>'
		            +'           <option value="undeliver">待发货</option>'
		            +'           <option value="consign">已发货</option>'
		            +'          <option value="complete">已完成</option>'
		            +'          <option value="canceled">已取消</option>'
		            +'        </select>'
		            +'        <input type="text" name="orderId" id="orderId" class="orderId" placeholder="请输入要搜索的订单号" value="">'
		            +'       <input type="button" class="btn_search " id="btn_search" value="搜索">'
		            +'   </form>'
		            +'</div>'
		            +' </div>';
		    if(!total){//无订单数据
		    	html+='<div style="height:335px; background:url('+'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_06.png'+') center center no-repeat; text-align:center;  font-size:22px; color:rgb(208,208,208);overflow:hidden;">'
		    	+'<p style="margin-top:250px;">没有订单</p><p><a href="/index.do" style="font-size:18px; margin-top:20px; text-decoration:none; color:rgb(108,81,180)"><strong>去购物</strong></a></p></div>';
		    	$(".page-article").append(html);
		    	 if(orderStatusGlobal){
		        	 $("#orderStatus").val(orderStatusGlobal);
		        }
		    	 $("#orderId").val(orderId);
		    	return;
		    }
	        if(!orderInfoRequestVoList){
	        	html+='<div style="height:335px; background:url('+'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_06.png'+') center center no-repeat; text-align:center;  font-size:22px; color:rgb(208,208,208);overflow:hidden;">'
		    	+'<p style="margin-top:250px;">没有订单</p></div>';
		    	$(".page-article").append(html);
	        	 if(orderStatusGlobal){
		        	 $("#orderStatus").val(orderStatusGlobal);
		        }
	        	 $("#orderId").val(orderId);
	        	return;
	        }
	        var l=0;
	        if(!$('#orderStatus').val()){
	        	$('#orderStatus').val("all");
	        }
	        for(var i=0;i<orderInfoRequestVoList.length;i++){
	        	var orderInfoRequestVo=orderInfoRequestVoList[i];
	        	html+='<div class="area_mend_body">'
	        		+'<div class="member_orders_title">'
	        		+' <span>'+orderInfoRequestVo.createtime+'</span> '
	        		+' <span><strong>订单号：</strong><a href="/order/orderInfo/lookOrderDetail.do?orderId='+orderInfoRequestVo.orderId+'">'+orderInfoRequestVo.orderId+'</a></span>';
	        		if(orderInfoRequestVo.orderStatus=='canceled'){
		        		html+='<i class="delete_ico" onclick="return deleteOrder( '+orderInfoRequestVo.orderId+' );"></i>';
		        	}
	        		if(orderInfoRequestVo.suppInfoVo){
	        			html+='<b>'+orderInfoRequestVo.suppInfoVo.sellerName+'</b>';
	        		}
	        	html+='</div><table class="member_file_list">';
	        	if(orderInfoRequestVo.orderItem&&orderInfoRequestVo.orderItem.length>0){
	        		for(var k=0;k<orderInfoRequestVo.orderItem.length;k++){
	            		var orderItemVO=orderInfoRequestVo.orderItem[k];
	            		l++;
	            		html+='<tr>'
	                		+'	<td>'
	                		+'  	<table class="chlie">'
	                		+'            <tr>'
	                		+'            	<td class="shop_g_img" valign="top">'
	                		+'                   <img class="imgJump" skuId="'+orderItemVO.goodsId+' " goodsType="'+orderItemVO.goodsType+' "  src="${imagepath}/'+orderItemVO.goodsImgUrl+'">'
	                		+'               </td>'
	                		+'              <td class="shop_g_info">'
	                		+'                  <h3 class="ship_g_h3"><a href="/order/orderInfo/lookOrderDetail.do?orderId='+orderInfoRequestVo.orderId+'">'+orderItemVO.name+'</a></h3>'
	                		+'                   <p class="ship_g_name">'+orderItemVO.addon+'</p>'
	                		+'                  <div class="ship_g_file">';
	                		var orderStatus=orderInfoRequestVo.orderStatus;
	                		if((orderStatus=='unauditing'||orderStatus=='unpay'||orderStatus=='paymentaudit'||orderStatus=='undeliver')&&orderItemVO.uploadFlag){
	                			html+='                       <p class="file_info_but">'
	                				+' <a href="javascript:" class="file_select_up">选择上传文件<!-- <i class="icon"></i>--></a>'
	                				+'<a href="javascript:" class="file_up webuploader-container" id="a'+orderItemVO.orderItemId+'" order_num="'+l+'" orderItemId="'+orderItemVO.orderItemId+'" order_id="'+orderInfoRequestVo.orderId+'">文件上传</a>'
	                				+'</p>'
	                		}else{
	                			html+='                       <p class="">'
	                				+' <a href="javascript:" ><!-- <i class="icon"></i>--></a>'
	                				+'<a href="javascript:" class=" webuploader-container" id="a'+orderItemVO.orderItemId+'" order_num="'+l+'" orderItemId="'+orderItemVO.orderItemId+'" order_id="'+orderInfoRequestVo.orderId+'"></a>'
	                				+'</p>'
	                		}
	                   html+='                      <p class="file_info_name">'
	                		+'      <span class="file_info_list">';
	        			if(orderItemVO.fileList&&orderItemVO.fileList.length>0){
	        				for(var q=0;q<orderItemVO.fileList.length;q++){
	        					var orderFileVo=orderItemVO.fileList[q];
	        	            	html+='<em><a href="javascript:" style="text-decoration:none">'+orderFileVo.fileName+'</a><i class="del" style="display: inline-block;'
	        	            	   		    +'width: 15px;height: 15px;cursor: pointer; margin-left: 15px; color: #f16c6c; line-height: 15px;text-align: center;" del_id="'+orderFileVo.foId+'">X</i></em>';
	        				}
	        			}
	        			html+='</span>'  ; 
	        			if(orderItemVO.fileList&&orderItemVO.fileList.length>1){      
	        				html+='<span class="moved"><em>更多</em><i class="icon" style="font-size:22px;"></i></span>';          
	                    }
	        			html+='</p>'
	        				+'</div>'
	        				+' </td>'
	        				+' <td>'
	        				+'  <div  class="shop_g_nume"> ￥'+orderItemVO.totalPrice+' </div>'
	        				+'</td>'
	        				+'</tr>'
	        				+'</table>'
	        				+' </td>';
	        				if(k<1){
	        					html+=' <td rowspan='+orderInfoRequestVo.orderItem.length+' style="border-right: 1px solid #f4f4f4;">'
		        				+'   <div class="shop_g_status">'+orderInfoRequestVo.orderStatusName+'</div>'
		        				+' </td>'
		        				+' <td rowspan='+orderInfoRequestVo.orderItem.length+'>'
		        				+'<div class="shop_g_actions">';
		        			if(orderInfoRequestVo.orderStatus=='unpay'){
		        				html+='<a href="/order/orderPay/goOrderPay.do?orderId='+orderInfoRequestVo.orderId+'" orderId="'+orderInfoRequestVo.orderId+'" target="_blank" class="  but_shop">立即付款</a>';
		        				html+='<a href="javascript:;" style="text-decoration:none" onclick="return cancelOrder( '+orderInfoRequestVo.orderId+' );" >取消订单</a>';
		        			} 
		        			if(orderInfoRequestVo.orderStatus=='consign'){
		        				html+='<a href="javascript:;" onclick="return confirmShipOrder( '+orderInfoRequestVo.orderId+' );" style="text-decoration:none">确认收货</a>';
		        			} 
		        			if(orderInfoRequestVo.orderStatus=='unauditing'){
		        				html+='<a href="javascript:;" style="text-decoration:none" onclick="return cancelOrder( '+orderInfoRequestVo.orderId+' );" >取消订单</a>';
		        			}
		        				html+='<a href="/order/orderInfo/lookOrderDetail.do?orderId='+orderInfoRequestVo.orderId+'" style="text-decoration:none"  class="btn btn-import">查看详情</a>';
		        			
		        			
	        				}
	        				
	        			html+='</div>'
	        				+'</td>'
	        				+' </tr>';
	        		}	
	        				
	        				html+='</table>';
	        	}	
	        			html+='</div>';
	        }		
	        $(".page-article").append(html);
	        if(orderStatusGlobal){
	        	 $("#orderStatus").val(orderStatusGlobal);
	        }
	        $("#orderId").val(orderId);
	        $(document).on('click','.but_shop',function(){
	        //	 var orderid=$(this).attr("orderId");
	        	 $.confirm('',"支付完成后请点击确定..",function(){
	        		 window.location.href = "/order/orderInfo/lookOrders.do";

	  			},'',false);
	        	 
	        	 //关闭
	             $(".popup-btn-close").click(function(){
	                 window.location.href = url;
	                 return false;
	             });


	    	 });
	        $(document).on('click','.imgJump',function(){
	        	var skuId =$(this).attr('skuId');
	        	var goodsType =$(this).attr('goodsType');
	        	window.location.href="/mall/skuProductDetails.do?goodsId="+skuId+"&goodsType="+goodsType;
	    	 });
	        $(document).on('click','.del',function(){
	    		var foIds=$(this).attr('del_id');
	    		var th_is=$(this);
	    		doAjax("/order/orderInfo/updateOrderFilesDel.json", 'post', {'foIds':foIds}, function(ret){
	    			 if(ret.code=='200'){
	    	               $.alert('success',"附件删除成功！");
	    	              
	    	           	if($(".file_info_list").find("em").length<=2)
	    	           		{
	    	           		th_is.parents(".file_info_name").find(".moved").css("display","none");
	    	           		}
	    	            th_is.parents("em").remove();
	    	           }
	    		 });
	    		
	    	 });
	    	
	    
	    	var array=[];
	    	$(".webuploader-container").each(function(i,o){
	    		array.push($(o).attr('id'))
	    	})
	    	   /*增加文件 0507 gaoyangdi*/
	        	$(".file_info_but").hover(function(e) {
	        		$(this).find('.file_up').css("display","block").end().find(".icon").text("7");
	        		$(this).find("div").css({"width":"100%","height":"60px"});
	        	
	        	},function(){
	        		$(this).find('.file_up').css("display","none").end().find(".icon").text("6");
	        	
	        	});

	    	//上传文件
	    	$.files_up_oss({
	    					id:array,//按钮id
	    			        url: "/oss/getSignatureNew",
	    			        dir: "order/orderImage/",
	    			        file_type: "jpg,png,gif,psd,ai,cdr,eps,ppt,word,excel,pdf,tiff,rar,zip,7z,gif",
	    			        size: "100mb",//mb
	    			        view_url: "https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/"	,
	    			        get_name:'local_name',
	    				},function(index_number,json){
	    	                var orderItemId=$(".webuploader-container").eq(index_number).attr('orderItemId');
	    	                var orderId=$(".webuploader-container").eq(index_number).attr('order_id');
	    					 if (json.Status == 'OK') {
	    						 var requestData={url:json.filename, 
	    								 name:json.filename,
	    								 size:json.size, 
	    								 type:json.mimeType,
	    								 uniqueId:orderItemId
	    			                		}
	    						 doAjax("/user/userAccessory/addAccessory.json", 'post', {'requestData':JSON.stringify(requestData)}, function(ret){
	    							 var fileIdList=[];
	    							 var fileId=ret.data.resultDtos[0].id;
	    							 fileIdList.push(fileId);
	    							 var orderFilesParamDto={orderId:orderId, 
	    									 orderItemId:orderItemId,
	    									 fileIdList:fileIdList 
	        			                		}
	    							 doAjax("/order/orderInfo/updateOrderFiles.json", 'post', {'requestData':JSON.stringify(orderFilesParamDto)}, function(ret){
	    								 if(ret.code=='200'){
	    				                        $.alert('success',"附件关联成功！");
	    				                        location.href = location.href;
	    				                        
	    				                    }
	    							 });
	    			                });
	    					 }
	    	})
	    	
	    }
	});

}




//删除订单
function deleteOrder(orderId){
    $.confirm("删除订单","您确认要删除该订单吗?",function(){
        doAjax('/order/orderInfo/updateOrderDel.json', 'post', {'orderId':orderId}, function(ret){
            if(ret.code=='200'){
                $.alert('success',"订单删除成功！");
                location.href = location.href;
            }
        });

    }, function(){$(".popup-btn-close").click();});

    return false;
}

function confirmShipOrder(orderId){
    doAjax('/order/orderInfo/updateOrderConfirmShip.json', 'post', {'orderId':orderId }, function(ret){
        if(ret.code=='200'){
            $.alert('success',"确认收货成功！");
            location.href = location.href;
        }
    });
    return false;
}

function cancelOrder(orderId){
    var str = '<input type="hidden" name="pop-orderId" value="'+ orderId +'">' +
            '<ul class="order_cancel">' +
            '<li class="form-item choose"><input type="radio" name="reasonType" value="0" checked="checked"> 不想要了</li>' +
            '<li class="form-item choose"><input type="radio" name="reasonType" value="1"> 支付不成功</li>' +
            '<li class="form-item choose"><input type="radio" name="reasonType" value="2"> 价格较贵</li>' +
            '<li class="form-item choose"><input type="radio" name="reasonType" value="3"> 缺货</li>' +
            '<li class="form-item choose"><input type="radio" name="reasonType" value="4"> 等待时间过长</li>' +
            '<li class="form-item choose"><input type="radio" name="reasonType" value="5"> 拍错了</li>' +
            '<li class="form-item choose"><input type="radio" name="reasonType" value="6"> 订单信息填写错误</li>' +
            '<li class="form-item choose"><input type="radio" name="reasonType" value="7"> 其他</li>' +
            '<li class="form-item choose"><input class="x-input" type="text" name="reasonDesc"></li>' +
            '<li class="form-item "><button type="submit" class="btn btn-caution act-subscribe btn-ordercancel">提交</button></li>' +
            '</ul>';

    $.prompt({
        style: '',
        title: '取消订单',
        con: str
    });

    return false;
}

//左侧页签
	var rhtml=$('.page-aside');
	var righthtml=$('.page-article');
	$('.small-page').empty();
	$('.small-page').append(rhtml);
	$('.small-page').append(righthtml);


var status=$("#editorderStatus").val() ; 
if(status){
	$("#orderStatus").val(status)  ;
}

$(document).on('click','.moved',function(){
    var h=$(this).parents(".file_info_name").find('.file_info_list')
     if(h.height()==30)
          {
          h.css("height","auto")
          }
      else{
         h.css("height","30px")
      }

})

$('#orders').css({'color':'#6647b2','font-weight':'900'});
</script>



